<template>
	<view class="content">
		<view class="form">
			<u-form ref="uForm">
				<view>
					<u-form-item border="true" label="学生姓名:" label-width="140" >
						<u-input v-model="name"  placeholder="请输入姓名"/>
					</u-form-item>
					<u-form-item border="true" label="手机号码:" label-width="140">
						<u-input v-model="number" placeholder="请输入手机号码"/>
					</u-form-item>
					<u-form-item border="true" label="毕业学校:" label-width="140">
						<u-input v-model="school" placeholder="请输入毕业学校"/>
					</u-form-item>
					<u-form-item border="true" label="咨询专业:" label-width="140">
						<u-input v-model="major" placeholder="请输入要咨询的专业"/>
					</u-form-item>
				</view>
				<u-button type="primary" style class="u-margin-top-40" @click="submit()">提交</u-button>
			</u-form>
		</view>
	
	</view>
</template>

<script>
	import request from "../../../util/request.js"
	import api from "../../../util/api.js"
	import check from "../../../util/check.js"
	export default {
		data() {
			return {
				name:"",
				number:"",
				school:"",
				major:"",
				form:""
			}
		},
		methods: {
			submit: function() {
					// let files = [];
					// files = this.$refs.uUpload.lists;
					// let filesArr = [];
					// for (var i = 0; i < files.length; i++) {
					// 	let url = files[i].response.data;
					// 	filesArr.push(url);
					// }
			
					// console.log(filesArr);
			
					let newForm = {};
					for (let key in this.form) {
						console.log(key + '---' + this.form[key])
						let newKeys = key.split("_");
						let newKey = newKeys[1];
						newForm[newKey] = this.form[key];
					}
					request.post(api.fieldsSubmit, {
						username: this.name,
						phone: this.number,
						school: this.school,
						major: this.major
						
					}).then(response => {
						console.log(response);
						
			
			
					}).catch(ex => {
						console.log(ex);
						uni.showToast({
							icon: 'none',
							title: '请求失败，请稍后再试'
						})
					})
				}
			
			}
			
		}
</script>

<style>
	.content {
		background-color: #f8f8f8;
		padding: 30rpx;
		min-height: 700px;
	}
	
	.form {
		background-color: #FFFFFF;
		padding: 20rpx;
	}
	
	.info_list_title {
		border-left: solid 10rpx #0095f0;
		padding: 0 10rpx;
		margin: 20rpx 0;
		font-size: 35rpx;
		font-weight: 500;
	}

</style>
